<?php
@include('include/common.inc.php');	
if($_POST['email'])
{
	$email = $_POST['email'];
	$sel ="select * from $TBL_MEM where email='$email'";
	$result =mysql_query($sel);
	if($row = mysql_fetch_array($result))
	{
		$id = $row[id];
		$rand = rand(10000,100000);
		$pass = md5($rand);
		$name = $row[name];
		$user_id = $row[user_id];
		$update = "update $TBL_MEM set  password='$pass' where id='$id'";
		if(mysql_query($update))
		{
			$sentemail = "$name,您好！ <br>
			&nbsp;&nbsp;&nbsp;&nbsp;你的賬號：$user_id<br>
			&nbsp;&nbsp;&nbsp;&nbsp;重置密碼為：$rand<br>
			請保管自己的密碼，以防泄露！";
			$_SESSION['ToEmail'] = $email;
			$_SESSION['ccon'] =$sentemail;
			$_SESSION['EM_REALNAME'] = '密碼重置';
			include_once('sentemail/password.php');
			exit();
		}
	}else{
		MyNotice("您輸入的郵件有誤!",1,'index.php'); 
	}
}
if($_POST['idk'])
{	
	$id = $row[id];
	$idk = $_POST['idk'];
	$sel ="select * from $TBL_MEM where idk='$idk'";
	$result =mysql_query($sel);
	if($row = mysql_fetch_array($result))
	{
		$rand = rand(10000,100000);
		$pass = md5($rand);
		$name = $row[name];
		$email = $row[email];
		$user_id = $row[user_id];
		$update = "update $TBL_MEM set password='$pass' where id='$id'";
		if(mysql_query($update))
		{
			$sentemail = "$name,您好！ <br>
			&nbsp;&nbsp;&nbsp;&nbsp;你的賬號：$user_id<br>
			&nbsp;&nbsp;&nbsp;&nbsp;重置密碼為：$rand<br>
			請保管自己的密碼，以防泄露！";
			$_SESSION['ToEmail'] = $email;
			$_SESSION['ccon'] =$sentemail;
			$_SESSION['EM_REALNAME'] = '密碼重置';
			include_once('sentemail/password.php');
			exit();
		}
	}else{
		MyNotice("您輸入的身份證有誤!",1,'index.php'); 
	}
}

if($_POST['mobile'])
{
	$id = $row[id];
	$moblie = $_POST['moblie'];
	$sel ="select * from $TBL_MEM where mobile='$mobile'";
	$result =mysql_query($sel);
	if($row = mysql_fetch_array($result))
	{
		$rand = rand(10000,100000);
		$pass = md5($rand);
		$name = $row[name];
		$user_id = $row[user_id];
		$email = $row[email];
		$update = "update $TBL_MEM set  password='$pass' where id='$id'";
		if(mysql_query($update))
		{				
			$sentemail = "$name,您好！ <br>
			&nbsp;&nbsp;&nbsp;&nbsp;你的賬號：$user_id<br>
			&nbsp;&nbsp;&nbsp;&nbsp;重置密碼為：$rand<br>
			請保管自己的密碼，以防泄露！";
			$_SESSION['ToEmail'] = $email;
			$_SESSION['ccon'] =$sentemail;
			$_SESSION['EM_REALNAME'] = '密碼重置';
			include_once('sentemail/password.php');
			exit();
		}
	}else{
		MyNotice("您輸入的手機號碼有誤!",1,'index.php'); 
	}
}
$smarty->assign("mem_id",$_SESSION['mem_id']);
$smarty->assign("type",$_SESSION['type']);
@include('number.php');//验证码
@include('right.php');
$smarty->display('findpass.html');

?>